package cn.wolfcode.cloud.productserver.service.impl;

import cn.wolfcode.cloud.productapi.domian.Product;
import cn.wolfcode.cloud.productapi.service.IProductService;
import cn.wolfcode.cloud.productserver.mapper.ProductMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper productMapper;

    @Value("${server.port}")
    private String port;


    @Override
    public List<Product> list() {
        return productMapper.list();
    }

    @Override
    public Product get(Long userId) {
        Product product = productMapper.find(userId);
        Product result = new Product();
        BeanUtils.copyProperties(product,result);
        result.setName(result.getName()+":"+ port);
        return result;
    }
}
